/*!
//      
//      \file	k2k_NanoX.h
//      
//      \author	Copyright 2010 Valentina Vuksic <vuksv1@bfh.ch>, Beat Liechti <liecb2@bfh.ch>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.
//
//		Defines and includes to work with Nano-X
//      
//      \brief		CAS-EBX-03 Projektarbeit 
//      			Valentina Vuksic (VUKSV1), Beat Liechti (LIECB2)
//      			k2k_NanoX ADT for the k2k (Kaffee2000) application
//      \version	1.0
//      \date		2010-04-19
//      \remark		Last Modifications:
//      \remark  	v1.0, VUKSV1/LIECB2, 2010-04-19 Initial release
//
*/

#ifndef __k2k_NanoX__
#define __k2k_NanoX__

#define k2k_NANOX_ERR_SUCCESS				0x00000000
#define k2k_NANOX_ERR_GROPEN_FAILED			0xFFFE0001

#define MWINCLUDECOLORS
#include <nano-X.h>	
#define LTBROWN			MWRGB( 224, 160 , 96 )
#define WIN_BORDER		5
#define TITLE 			"k2 kaffee"
#define TITLE_X			30
#define TITLE_Y			9

/*! Default font name and location */
#if defined(CARME) || defined(ORCHID)
#define FONTNAME	"/usr/local/mwin/fonts/truetype/arial.ttf"
#elif defined(X86)
#define FONTNAME	"/carme/microwin_x86/src/fonts/truetype/arial.ttf"
#endif

#define RSTR_ICON_COLOR	LTMAGENTA
#define ESPR_ICON_COLOR	LTRED
#define MLKC_ICON_COLOR	LTCYAN

/*!
// k2k_NanoX defines the data structure for the ADT 
// \brief k2k_NanoX stuct for ADT
*/				
typedef struct k2k_NanoX_Struct
{	
	/*! information about the screen */	
	GR_SCREEN_INFO  screenInfo;
	/*! window size */
	int	winSizeX, winSizeY;
	/*! main window */
	GR_WINDOW_ID gRootWinID;
	/*! title */
	GR_GC_ID gTitleID;
	/*! on/off indication */
	GR_GC_ID gOnOffID;
	/*! delimiter line graphic context  */
	GR_GC_ID gDelimID;
	/*! GC for state text */
	GR_GC_ID gStateTextID;
	/*! last state text displayed */
	char *lastStateText;
	/*! GC for Rstr text */
	GR_GC_ID gRstrTextID;
	/*! GC for Rstr button */
	GR_GC_ID gRstrIconID;
	/*! GC for Rstr animation */
	GR_GC_ID gRstrAnimID;
	/*! GC for Espr text */
	GR_GC_ID gEsprTextID;
	/*! GC for icon */
	GR_GC_ID gEsprIconID;
	/*! GC for activitiy indicator */
	GR_GC_ID gEsprAnimID;
	/*! GC for MlkC text */
	GR_GC_ID gMlkCTextID;
	/*! GC for MlkC icon */
	GR_GC_ID gMlkCIconID;
	/*! GC for MlkC activitiy indicator */
	GR_GC_ID gMlkCAnimID;
	/*! GC for coffee cups */
	GR_GC_ID gCupID;	
	/*! GC for coffee cup underlines */
	GR_GC_ID gCupLineID;		
	/*! error code to signal initialization errors */
	int err;
} k2k_NanoX;

/*!
//
// Creates nanoX ADT "object"
// 
// \return pointer to the nanoX ADT
//
*/
k2k_NanoX* k2k_NanoX_Create();

/*!
//
// Releases nanoX ADT "object"
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return noting
//
*/
void k2k_NanoX_Release(k2k_NanoX *nanoX);

/*!
//
// Draw the main button indicating ON or OFF
// 
// \param mainButtonColor is the color for the on/off button
// 
// \return nothing
//
*/
void k2k_NanoX_DrawOnOffButton(k2k_NanoX *nanoX, MWCOLORVAL mainButtonColor);

/*!
//
// Blink the main button 
// 
// \param mainButtonColor1 is the first color
// \param mainButtonColor2 is the second color
// 
// \return nothing
//
*/
void k2k_NanoX_BlinkOnOffButton(k2k_NanoX *nanoX, MWCOLORVAL mainButtonColor1, MWCOLORVAL mainButtonColor2, int *blinkCounter);

/*!
//
// Displays state text
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// \param stateText is the string to display
// 
// \return nothing
//
*/
void k2k_NanoX_ShowStateText(k2k_NanoX *nanoX, char *stateText);

/*!
//
// Show or hide the two coffee cup icons
// 
// \param cup1Color is the color for the first cup
// \param cup1Color is the color for the second cup
// 
// \return nothing
//
*/
void k2k_NanoX_DrawCups(k2k_NanoX *nanoX, MWCOLORVAL cup1Color, MWCOLORVAL cup2Color);

/*!
//
// Blink the coffee cup icons
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// \param fillDegreee is the level of the coffeee
// \param coffeeCount is the number of coffees to make
// \param coffeeCountDone is the number of coffees already made
// 
// \return nothing
//
*/
void k2k_NanoX_BlinkCups(k2k_NanoX *nanoX, int fillDegreee, int coffeeCount, int coffeeCountDone);

/*!
//
// Displays text for Rstr
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowRstrText(k2k_NanoX *nanoX);

/*!
//
// Deletes text for Rstr by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideRstrText(k2k_NanoX *nanoX);

/*!
//
// Displays icon for Rstr
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowRstrIcon(k2k_NanoX *nanoX);

/*!
//
// Deletes icon for Rstr by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideRstrIcon(k2k_NanoX *nanoX);

/*!
//
// Update Rstr animation
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// \param fillDegree is the pointer to the level of the coffee
// 
// \return nothing
//
*/
void k2k_NanoX_UpdateRstrAnimation(k2k_NanoX *nanoX, int *fillDegree);

/*!
//
// Displays text for Espr
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowEsprText(k2k_NanoX *nanoX);

/*!
//
// Deletes text for Espr by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideEsprText(k2k_NanoX *nanoX);

/*!
//
// Displays icon for Espr
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowEsprIcon(k2k_NanoX *nanoX);

/*!
//
// Deletes icon for Espr by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideEsprIcon(k2k_NanoX *nanoX);

/*!
//
// Update Espr animation
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// \param fillDegree is the pointer to the level of the coffee
// 
// \return nothing
//
*/
void k2k_NanoX_UpdateEsprAnimation(k2k_NanoX *nanoX, int *fillDegree);

/*!
//
// Displays text for MlkC
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowMlkCText(k2k_NanoX *nanoX);

/*!
//
// Deletes text for MlkC by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideMlkCText(k2k_NanoX *nanoX);

/*!
//
// Displays icon for MlkC
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_ShowMlkCIcon(k2k_NanoX *nanoX);

/*!
//
// Deletes icon for MlkC by writing it in black
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// 
// \return nothing
//
*/
void k2k_NanoX_HideMlkCIcon(k2k_NanoX *nanoX);

/*!
//
// Update MlkC animation
// 
// \param nanoX is the pointer to the k2k_NanoX structure 
// \param fillDegree is the pointer to the level of the coffee
// 
// \return nothing
//
*/
void k2k_NanoX_UpdateMlkCAnimation(k2k_NanoX *nanoX, int *fillDegree);

#endif
